package com.ruoyi.web.controller.wnjk.app.shop;




import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.wnjk.domain.dto.PhysicalDTO;
import com.ruoyi.system.wnjk.domain.po.Physical;
import com.ruoyi.system.wnjk.service.IPhysicalService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/package")
public class AppPackageController extends BaseController {
    @Autowired
    private IPhysicalService physicalService;

    /**
     * 分页+搜索
     * @param
     * @return
     */
    @Operation(summary = "分页+搜索")
    @PostMapping("/list")
    public TableDataInfo listSearch(PhysicalDTO physicalDTO){
        List<Physical>  physicalList = physicalService.listSearch(physicalDTO);
        return getDataTable(physicalList);
    }

    // 查询单个套餐详情，通过 id
    @GetMapping( "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(physicalService.selectWnjkPhysicalExaminationPackageById(id));
    }

    // 查询某医院的所有套餐，通过 hospitalId
    @GetMapping("/byHospital")
    public AjaxResult getPackagesByHospitalId(@RequestParam("hospitalId") Long hospitalId) {
        return success(physicalService.selectWnjkPhysicalExaminationPackageByHospitalId(hospitalId));
    }
}
